import { Component, Input } from '@angular/core';
import { FieldMapConfig } from 'src/components/scenarios/models';

@Component({
  selector: 'app-field-map-list',
  templateUrl: './field-map-list.component.html',
  styleUrl: './field-map-list.component.scss'
})
export class FieldMapListComponent {
  private _fields: FieldMapConfig[] = [];
  @Input()
  public get fields(): FieldMapConfig[] {
    return this._fields;
  }
  public set fields(value: FieldMapConfig[]) {
    this._fields = value;
  }

  private _values: { [key: string]: any; } = {};
  @Input()
  public get values(): { [key: string]: any; } {
    return this._values;
  }
  public set values(value: { [key: string]: any; }) {
    this._values = value;
  }

  valueMapDescription(field: FieldMapConfig, value: any) {
    const map = field.Maps.find(a => a.Key == value);
    if (map) {
      return map.Description;
    }
    return "";
  }
  valueMapColor(field: FieldMapConfig, value: any) {
    const map = field.Maps.find(a => a.Key == value);
    if (map) {
      return map.Color;
    }
    return "";
  }
}
